<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    html{
      font-size: 20px;
    }
    .wrap{
      width: 10rem;
      height: 5rem;
      border: 1px solid #000;
      text-align: center;
      line-height: 100px;
      margin: 0 auto;
      margin-top: 50px;
      font-size: 20px;
    }
    /* @media screen and (min-width: 400px){
      html{
        font-size: 24px;
      }
    } */
    /* @media screen and (max-width: 400px){
      .wrap{
      width: 160px;
      }
    } */ 
  </style>
  <script>
    (function(wimdow) {
      let phoneWidth = document.documentElement.clientWidth
      let fontS = phoneWidth / 10
      document.documentElement.style.fontSize = fontS + 'px'
      // console.log(phoneWidth);
    })(window)
  </script>
</head>
<body>
  <div class="wrap">
    hello world
  </div>
</body>
</html>